package org.example.ims.Exception;


import org.example.ims.DTO.Response;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import static org.example.ims.DTO.Response.error;

@RestControllerAdvice
public class GlobalExceptionHandler {

    // 可以添加更多的异常处理方法
    @ExceptionHandler(RuntimeException.class)
    public ResponseEntity<Response> handleGeneralException(RuntimeException ex) {
        Response errorResponse = Response.error("INTERNAL_SERVER_ERROR", ex.getMessage());
        return new ResponseEntity<>(errorResponse, HttpStatus.INTERNAL_SERVER_ERROR);
    }
}